package screen_calibration;
/*************************************************
 * File:	DecimalPlaces.java
 * Description:	render a string representing a double
 *    with specified number of decimal places.
 *
 * Author: Gene Vishnevsky  Oct. 15, 1997
*************************************************/

/**
* This class produces a method to render a string representing
* a double value with specified number of decimal places.
* 
*/
public final class DecimalPlaces {

	private DecimalPlaces() {}

	/**
	* Render a String representing a double with specified number of decimal
	* places.
	* @param x the value to convert to a string.
	* @param m number of decimal places.
	*/
	public static String render( double x, int m ) {

		String s = String.valueOf( x );

		int k = s.indexOf( '.' ) + m + 1;		// last index

		int l = s.length();

		return s.substring( 0, Math.min( k, l ) );
	}
}

